<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>四六级报名倒计时</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #333;
        }
        
        .container {
            background: white;
            padding: 40px;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 600px;
            width: 90%;
            transition: transform 0.3s ease;
        }
        
        .container:hover {
            transform: translateY(-5px);
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 30px;
            background: linear-gradient(135deg, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .countdown {
            display: flex;
            justify-content: space-around;
            margin: 30px 0;
        }
        
        .time-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px 15px;
            border-radius: 15px;
            min-width: 120px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        }
        
        .time-value {
            font-size: 2.8rem;
            font-weight: bold;
            line-height: 1.2;
        }
        
        .time-label {
            font-size: 0.9rem;
            margin-top: 5px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .message {
            font-size: 1.2rem;
            margin-top: 30px;
            color: #666;
            line-height: 1.6;
        }
        
        .settings {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }
        
        .settings h3 {
            margin-bottom: 15px;
            color: #555;
        }
        
        .form-group {
            margin-bottom: 15px;
            text-align: left;
        }
        
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
            color: #666;
        }
        
        input[type="date"],
        input[type="time"],
        input[type="text"] {
            width: 100%;
            padding: 10px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }
        
        input[type="date"]:focus,
        input[type="time"]:focus,
        input[type="text"]:focus {
            outline: none;
            border-color: #667eea;
        }
        
        button {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 30px;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: 10px;
        }
        
        button:hover {
            transform: scale(1.05);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }
        
        .status {
            margin-top: 20px;
            padding: 15px;
            border-radius: 10px;
            font-weight: 500;
        }
        
        .status.urgent {
            background-color: #ffebee;
            color: #c62828;
            border-left: 4px solid #c62828;
        }
        
        .status.warning {
            background-color: #fff8e1;
            color: #f57c00;
            border-left: 4px solid #f57c00;
        }
        
        .status.normal {
            background-color: #e8f5e9;
            color: #2e7d32;
            border-left: 4px solid #2e7d32;
        }
        
        .current-time {
            position: fixed;
            top: 20px;
            right: 20px;
            background: rgba(255, 255, 255, 0.9);
            padding: 10px 20px;
            border-radius: 30px;
            font-size: 1rem;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
        
        @media (max-width: 600px) {
            .container {
                padding: 30px 20px;
            }
            
            h1 {
                font-size: 2rem;
            }
            
            .countdown {
                flex-wrap: wrap;
                gap: 10px;
            }
            
            .time-box {
                min-width: calc(50% - 10px);
            }
            
            .time-value {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <div class="current-time" id="current-time"></div>
    
    <div class="container">
        <h1>四六级报名倒计时</h1>
        
        <div class="countdown">
            <div class="time-box">
                <div class="time-value" id="days">00</div>
                <div class="time-label">天</div>
            </div>
            <div class="time-box">
                <div class="time-value" id="hours">00</div>
                <div class="time-label">小时</div>
            </div>
            <div class="time-box">
                <div class="time-value" id="minutes">00</div>
                <div class="time-label">分钟</div>
            </div>
            <div class="time-box">
                <div class="time-value" id="seconds">00</div>
                <div class="time-label">秒</div>
            </div>
        </div>
        
        <div class="message">距离报名截止还有 <span id="time-remaining"></span></div>
        
        <div class="status" id="status"></div>
        
        <div class="settings">
            <h3>自定义截止时间</h3>
            <div class="form-group">
                <label for="target-date">选择截止日期：</label>
                <input type="date" id="target-date">
            </div>
            <div class="form-group">
                <label for="target-time">选择截止时间：</label>
                <input type="time" id="target-time">
            </div>
            <div class="form-group">
                <label for="event-name">事件名称（可选）：</label>
                <input type="text" id="event-name" placeholder="例如：英语四级报名">
            </div>
            <button onclick="updateCountdown()">更新倒计时</button>
        </div>
    </div>

    <script>
        // 默认截止时间（2024年12月大学英语六级考试报名时间为例）
        let targetDate = new Date('2024-12-15T23:59:59');
        let eventName = '英语四六级报名';
        
        // 更新当前时间显示
        function updateCurrentTime() {
            const now = new Date();
            const timeElement = document.getElementById('current-time');
            timeElement.textContent = now.toLocaleString('zh-CN');
        }
        
        // 更新倒计时
        function updateCountdown() {
            // 获取用户输入的截止时间
            const dateInput = document.getElementById('target-date').value;
            const timeInput = document.getElementById('target-time').value;
            const nameInput = document.getElementById('event-name').value;
            
            // 如果用户输入了日期和时间，则更新目标时间
            if (dateInput && timeInput) {
                targetDate = new Date(`${dateInput}T${timeInput}`);
                
                // 如果浏览器解析失败，尝试另一种格式
                if (isNaN(targetDate.getTime())) {
                    const [year, month, day] = dateInput.split('-');
                    const [hour, minute] = timeInput.split(':');
                    targetDate = new Date(year, month - 1, day, hour, minute, 59);
                }
            }
            
            // 更新事件名称
            if (nameInput) {
                eventName = nameInput;
                document.querySelector('h1').textContent = `${eventName}倒计时`;
            }
            
            // 立即更新倒计时显示
            calculateTimeRemaining();
        }
        
        // 计算并显示剩余时间
        function calculateTimeRemaining() {
            const now = new Date();
            const difference = targetDate - now;
            
            let days, hours, minutes, seconds;
            
            // 判断是否已经过期
            if (difference <= 0) {
                days = 0;
                hours = 0;
                minutes = 0;
                seconds = 0;
                document.getElementById('status').textContent = `${eventName}已截止！`;
                document.getElementById('status').className = 'status urgent';
            } else {
                // 计算剩余时间
                days = Math.floor(difference / (1000 * 60 * 60 * 24));
                hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
                seconds = Math.floor((difference % (1000 * 60)) / 1000);
                
                // 更新状态提示
                updateStatus(days, hours);
            }
            
            // 更新显示
            document.getElementById('days').textContent = days.toString().padStart(2, '0');
            document.getElementById('hours').textContent = hours.toString().padStart(2, '0');
            document.getElementById('minutes').textContent = minutes.toString().padStart(2, '0');
            document.getElementById('seconds').textContent = seconds.toString().padStart(2, '0');
            
            // 更新文字描述
            let timeRemainingText = '';
            if (days > 0) timeRemainingText += `${days} 天 `;
            if (hours > 0 || days > 0) timeRemainingText += `${hours} 小时 `;
            timeRemainingText += `${minutes} 分钟 ${seconds} 秒`;
            
            document.getElementById('time-remaining').textContent = timeRemainingText;
        }
        
        // 根据剩余时间更新状态提示
        function updateStatus(days, hours) {
            const statusElement = document.getElementById('status');
            
            if (days === 0 && hours <= 24) {
                statusElement.textContent = '紧急提醒：报名即将截止！请立即完成！';
                statusElement.className = 'status urgent';
            } else if (days <= 3) {
                statusElement.textContent = '温馨提示：距离报名截止还有不到3天，请尽快完成报名';
                statusElement.className = 'status warning';
            } else {
                statusElement.textContent = '报名时间充裕，请合理安排时间完成报名';
                statusElement.className = 'status normal';
            }
        }
        
        // 初始化页面
        function init() {
            // 设置默认日期和时间（可选）
            const tomorrow = new Date();
            tomorrow.setDate(tomorrow.getDate() + 7);
            const defaultDate = tomorrow.toISOString().split('T')[0];
            const defaultTime = '23:59';
            
            document.getElementById('target-date').value = defaultDate;
            document.getElementById('target-time').value = defaultTime;
            document.getElementById('event-name').value = '英语四六级报名';
            
            // 立即更新一次
            updateCurrentTime();
            calculateTimeRemaining();
            
            // 设置定时器
            setInterval(updateCurrentTime, 1000);
            setInterval(calculateTimeRemaining, 1000);
        }
        
        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', init);
    </script>
</body>
</html>